package com.tuanzi.loan.business.service.sms;

import com.tuanzi.loan.business.constants.sms.SmsVoiceSendTaskStatus;
import com.tuanzi.loan.business.entity.sms.SmsVoiceSendTask;
import com.tuanzi.loan.core.service.CommonService;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.family.sms.SmsVoiceSendTaskSearchRequest;
import com.tuanzi.loan.vo.response.family.sms.SmsVoiceSendTaskSearchResponse;
import lombok.Data;
import org.springframework.data.domain.Page;

import java.util.Date;
import java.util.Map;

/**
 * @Author: chenweijun
 * @Date: 2018/10/22 11:38
 * @Description: 语音短信发送Service
 */
public interface SmsVoiceSendTaskService extends CommonService<SmsVoiceSendTask, Long> {

    SmsVoiceSendTask addSmsVoiceSendTask(Long calculateTaskId);

    void sendVoiceSms(SmsVoiceSendTask smsVoiceSendTask);

    Long countByStatus(SmsVoiceSendTaskStatus status);

    SmsVoiceSendTask findTopOneByStatusAndExecuteTimeBefore(SmsVoiceSendTaskStatus status, Date executeDate);

    void updateStatusWithoutTransactional(SmsVoiceSendTask smsVoiceSendTask, SmsVoiceSendTaskStatus status);

    Page<SmsVoiceSendTaskSearchResponse> list(PageSearcher<SmsVoiceSendTaskSearchRequest> pageSearcher);

    void cancelTask(Long smsVoiceSendTaskId);

    SmsVoiceSendTask resend(Long smsVoiceSendTaskId);

    Map<String, String> findDistinctFirstNames();

    @Data
    final class SmsVoicePlatformResult {
        private String status;

        private String message;

        private Long remainPoint;

        private String taskId;

        private Long successCounts;

        public boolean isSuccess() {
            return "Success".equalsIgnoreCase(status);
        }
    }
}
